# -*- coding: utf-8 -*-
# https://blog.csdn.net/weixin_52040868
# 公众号：测个der
# 微信：qing_an_an

from PyQt5.QtWidgets import *
import sys


class GWIN(QWidget):
    def __init__(self):
        super(GWIN, self).__init__()
        self.initUI()

    def initUI(self):
        grid= QGridLayout()
        self.setLayout(grid)
        names = ['CLS','BLACK','','CLOSE',
                 '7','8','9','/',
                 '4','5','6','*',
                 '1','2','3','-',
                 '0','.','=','+']
        # 位置坐标
        positions = [(i,j) for i in range(5) for j in range(4)]
        for position,name in zip(positions,names):
            if name == '':  # 不显示空白按钮
                continue
            button = QPushButton(name)
            # 添加进网格,按照一定顺序0,0  0,1  0,2  0,3
            grid.addWidget(button,*position)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    gwin = GWIN()
    gwin.show()
    sys.exit(app.exec_())